﻿#include "pch.h"
#include "TitleBarControl.xaml.h"
#if __has_include("TitleBarControl.g.cpp")
#include "TitleBarControl.g.cpp"
#endif



namespace winrt::NovelReader::implementation
{
    TitleBarControl::TitleBarControl()
    {
        m_viewModel = winrt::NovelReader::TitleBarViewModel(); 
        m_userSettings = winrt::NovelReader::AppService::UserSettings(); 
    }

    void TitleBarControl::InitializeComponent()
    {
        TitleBarControlT::InitializeComponent(); 
        this->ApplySettings(); 
    }

    winrt::NovelReader::TitleBarViewModel TitleBarControl::ViewModel()
    {
        return m_viewModel; 
    }

    void TitleBarControl::ApplySettings()
    {
        this->UpdateRadioFlyoutMenuItemStatus<winrt::hstring>(m_fontNamesMenu(), m_userSettings.FontName());
        this->UpdateRadioFlyoutMenuItemStatus<int32_t>(m_themesMenu(), m_userSettings.ThemeIndex()); 
        this->UpdateRadioFlyoutMenuItemStatus<int32_t>(m_whiteLinesMenu(), m_userSettings.WhiteLines()); 
        this->UpdateRadioFlyoutMenuItemStatus<int32_t>(m_autoTurnPageSpeedMenu(), m_userSettings.AutoTurnPageSpeed()); 
    }
}
